var hljJs = new Object();
hljJs.getUserid=function(obj){
	try{
		if(isAppSupportFunc('get_userid')){
			if(isIos()){
				var userid = get_userid();
				obj.success(userid);
			}else{
				var userid = yahlj.get_userid();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.getUserToken=function(obj){
	try{
		if(isAppSupportFunc('get_user_token')){
			if(isIos()){
				var token = get_user_token();
				obj.success(token);
			}else{
				var token = yahlj.get_user_token();
				obj.success(token);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.checkWebAuth=function(key,obj){
	try{
		if(isAppSupportFunc('checkWebAuth')){
			if(isIos()){
				var token = checkWebAuth(key);
				obj.success(token);
			}else{
				var token = yahlj.checkWebAuth(key);
				obj.success(token);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.callAlipay=function(orderInfo,obj){
	try{
		if(isAppSupportFunc('callAlipay')){
			if(isIos()){
				var result = callAlipay(orderInfo);
				obj.success(result);
			}else{
				var result = yahlj.callAlipay(orderInfo);
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail(e.message);
	}
}

hljJs.checkWebAuth=function(key,obj){
	try{
		if(isAppSupportFunc('checkWebAuth')){
			if(isIos()){
				var token = checkWebAuth(key);
				obj.success(token);
			}else{
				var token = yahlj.checkWebAuth(key);
				obj.success(token);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.getSelectedCommunityid=function(obj){
	try{
		if(isAppSupportFunc('get_selected_communityid')){
			if(isIos()){
				var userid = get_selected_communityid();
				obj.success(userid);
			}else{
				var userid = yahlj.get_selected_communityid();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.getOsType=function(obj){
	try{
		if(isAppSupportFunc('get_os_type')){
			if(isIos()){
				var userid = get_os_type();
				obj.success(userid);
			}else{
				var userid = yahlj.get_os_type();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.getAppVersion=function(obj){
	try{
		if(isAppSupportFunc('get_app_version')){
			if(isIos()){
				var userid = get_app_version();
				obj.success(userid);
			}else{
				var userid = yahlj.get_app_version();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}


hljJs.getAppid=function(obj){
	try{
		if(isAppSupportFunc('get_appid')){
			if(isIos()){
				var userid = get_appid();
				obj.success(userid);
			}else{
				var userid = yahlj.get_appid();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.getDeviceModel=function(obj){
	try{
		if(isAppSupportFunc('get_device_model')){
			if(isIos()){
				var userid = get_device_model();
				obj.success(userid);
			}else{
				var userid = yahlj.get_device_model();
				obj.success(userid);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail");
	}
}

hljJs.setTipNum4Life=function(id,num,obj){
	try{
		if(isAppSupportFunc('setTipNum4Life')){
			if(isIos()){
				var result = setTipNum4Life(id,num);
				obj.success(result);
			}else{
				var result = yahlj.setTipNum4Life(id,num);
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail,e="+e.message);
	}
}

hljJs.scanCode=function(obj){
	try{
		if(isAppSupportFunc('scanCode')){
			if(isIos()){
				var result = scanCode();
				obj.success(result);
			}else{
				var result = yahlj.scanCode();
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail,e="+e.message);
	}
}

hljJs.closeWindow=function(obj){
	try{
		if(isAppSupportFunc('closeWindow')){
			if(isIos()){
				var result = closeWindow();
				obj.success(result);
			}else{
				var result = yahlj.closeWindow();
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail,e="+e.message);
	}
}

hljJs.scanBlue=function(obj){
	try{
		if(isAppSupportFunc('scanBlue')){
			if(isIos()){
				var result = scanBlue();
				obj.success(result);
			}else{
				var result = yahlj.scanBlue();
				result = JSON.parse(result);
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail,e="+e.message);
	}
}

hljJs.userLogin=function(userid,token,tel,obj){
	try{
		if(isAppSupportFunc('userLogin')){
			if(isIos()){
				var result = userLogin(userid,token,tel);
				obj.success(result);
			}else{
				var result = yahlj.userLogin(userid,token,tel);
				obj.success(result);
			}	
		}else{
			obj.fail("-1000");	
		}
	}catch(e){
		obj.fail("function is fail,e="+e.message);
	}
}



function isAppSupportFunc(name){
	try{
		var code = '-1';
		if(isIos()){
			code = is_support_function(name);
		}else{
			 code = yahlj.is_support_function(name);
		}
		if(code=='1'){
			return true;
		}else{
			return false;
		}
	}catch(e){
		return false;
	}
}

function isIos(){
	var ua = navigator.userAgent.toLowerCase();	
	if (/iphone|ipad|ipod/.test(ua)) {
		return true;
	}else{
		return false;
	}
		
}